#region Using References

using System;
using System.Threading.Tasks;

#endregion

namespace Beaker.Services.Tasks
{
	public interface ITaskCollection<T>
	{
		/// <summary>
		/// Starts the given task and expects a result
		/// </summary>
		/// <typeparam name="T">The type of the result</typeparam>
		/// <param name="func">The function executing the task and returning the result</param>
		/// <returns>The task that will result at some point a result of type T</returns>
		Task<T> Execute( Func<T> func );

		/// <summary>
		/// Observes the results of all the tasks in the collection
		/// </summary>
		/// <typeparam name="T">The type of the result</typeparam>
		/// <param name="keepOrder">Set to true to keep the order of the results</param>
		/// <returns>An observable to observe the results asynchronously</returns>
		IObservable<T> ObserveResults( bool keepOrder = false );
	}
}